package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.pojo.Student;
import com.itheima.pojo.StudentQueryParam;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface StudentMapper {

    /**
     * 学员列表查询（分页查询）
     *
     * @param studentQueryParam
     * @return
     */
    Page<Student> pageQuery(StudentQueryParam studentQueryParam);

    /**
     * 批量删除学员
     *
     * @param ids
     * @return
     */
//    void delete(Integer[] ids);
    void delete(List<Integer> ids);


    /**
     * 添加学员
     *
     * @param student
     */
    void insert(Student student);


    /**
     * 根据学生id查询学生信息
     *
     * @param id
     * @return
     */
    @Select("select * from student where id = #{id}")
    Student getByStudentId(Integer id);


    /**
     * 更新学员信息（修改学员）
     *
     * @param student
     * @return
     */
    void update(Student student);


    /**
     * 根据学生id查询总的违纪次数和违纪分数
     *
     * @param id
     * @return
     */
    @Select("select violation_count,violation_score from student where id = #{id}")
    Student selectCountAndScore(Integer id);


    /**
     * 违纪处理
     *
     * @param student
     */
    @Update("update student set violation_count = #{violationCount},violation_score = #{violationScore},update_time = #{updateTime} where id = #{id}")
    void violation(Student student);


    /**
     * 批量导入学员信息
     *
     * @param studentList
     */
    void insertBatch(List<Student> studentList);
}
